package migrator

import (
	"mig/pkg/data"
	"mig/pkg/types"
)

type DigestMigrator struct {
	chunkSize  int64
	maxWorkers int
}

func NewDigestMigrator(chunkSize int64, maxWorkers int) *DigestMigrator {
	return &DigestMigrator{
		chunkSize:  chunkSize,
		maxWorkers: maxWorkers,
	}
}

func (d *DigestMigrator) Migrate(source data.Database, target data.Database, unequalChunks []types.UnequalChunk) (*types.IntegrityInfo, error) {
	digests, err := simpleMigrate(source, target, d.chunkSize, d.maxWorkers, unequalChunks)
	if err != nil {
		return nil, err
	}
	return types.NewDigestIntegrityInfo(digests), nil
}
